<?PHP

$password = $_POST['password'];
$email = $_POST['email'];

$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2); //设置超时时间
$mysqli->real_connect('127.0.0.1', 'root', 'mysql');
$sql = "CREATE DATABASE IF NOT EXISTS CUPT DEFAULT CHARSET utf8 COLLATE utf8_general_ci;";
if ($mysqli->query($sql) == TRUE) {
    //printf("Table CUPT successfully created.\n");
}
mysqli_select_db($mysqli, "CUPT");

$sql = "select * from volunteer where `email`='$email' and `password`='$password';";
$rst = $mysqli->query($sql);
if ($rst->num_rows < 1) {
    echo '<br />用户名或密码错误！<br />';
    echo '<a href="javascript :;" onClick="javascript :history.back(-1);">回到登录界面</a>';
} else {
    echo '<br />登录成功';
    while ($row = mysqli_fetch_assoc($rst)) {
        if($row['secret_key']==null){$flag=0;}else{$flag=1;}
    }
    mysqli_close($mysqli);
    header("Location: volunteer-index.html?email=$email&flag=$flag");
    exit;
}
?>
